﻿using System;
using System.ServiceProcess;

namespace ServiceHost
{
    public partial class ServiceHost : ServiceBase
    {
        private readonly AppHost _appHost;
        public ServiceHost()
        {
            InitializeComponent();
            _appHost = new AppHost();
        }

        protected override void OnStart(string[] args)
        {
            try
            {
                const string listeningOn = "http://pc03:3010/";
                _appHost.Init();
                _appHost.Start(listeningOn);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
        protected override void OnStop()
        {
            _appHost.Stop();
        }

        public void StartManuel()
        {
            OnStart(null);
        }
        public void StopManuel()
        {
            OnStop();
        }
    }
}
